package com.ruoyi.parcel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.parcel.domain.EOrderProcess;
import com.ruoyi.parcel.service.IEOrderProcessService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * EOrderProcessController
 *
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/parcel/process")
public class EOrderProcessController extends BaseController {
    @Autowired
    private IEOrderProcessService eOrderProcessService;

    /**
     * 查询EOrderProcess列表
     */
    @RequiresPermissions("parcel:parcel:list")
    @GetMapping("/list")
    public TableDataInfo list(EOrderProcess eOrderProcess) {
        startPage();
        List<EOrderProcess> list = eOrderProcessService.selectEOrderProcessList(eOrderProcess);
        return getDataTable(list);
    }

    /**
     * 导出EOrderProcess列表
     */
    @RequiresPermissions("parcel:parcel:export")
    @Log(title = "EOrderProcess", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EOrderProcess eOrderProcess) {
        List<EOrderProcess> list = eOrderProcessService.selectEOrderProcessList(eOrderProcess);
        ExcelUtil<EOrderProcess> util = new ExcelUtil<EOrderProcess>(EOrderProcess.class);
        util.exportExcel(response, list, "EOrderProcess数据");
    }

    /**
     * 获取EOrderProcess详细信息
     */
    @RequiresPermissions("parcel:parcel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(eOrderProcessService.selectEOrderProcessById(id));
    }

    /**
     * 新增EOrderProcess
     */
    @RequiresPermissions("parcel:parcel:add")
    @Log(title = "EOrderProcess", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EOrderProcess eOrderProcess) {
        return toAjax(eOrderProcessService.insertEOrderProcess(eOrderProcess));
    }

    /**
     * 修改EOrderProcess
     */
    @RequiresPermissions("parcel:parcel:edit")
    @Log(title = "EOrderProcess", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EOrderProcess eOrderProcess) {
        return toAjax(eOrderProcessService.updateEOrderProcess(eOrderProcess));
    }

    /**
     * 删除EOrderProcess
     */
    @RequiresPermissions("parcel:parcel:remove")
    @Log(title = "EOrderProcess", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(eOrderProcessService.deleteEOrderProcessByIds(ids));
    }

    @PostMapping("/select/{orderNumber}")
    public List<EOrderProcess> select(@PathVariable String orderNumber) {
        System.out.println(eOrderProcessService.selectByOrderNumber(orderNumber));
        return eOrderProcessService.selectByOrderNumber(orderNumber);
    }

}
